package com.ymatou.iapi.coupon.testcase;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.coupon.parameter.GetValidBatchesBySellerResp;
import com.ymatou.iapi.coupon.parameter.GetValidBatchesBySellerResp.BatchVo;
import com.ymatou.iapi.coupon.parameter.getValidBatchesBySellerBean;
import com.ymatou.iapi.coupon.service.getValidBatchesBySellerCall;
import com.ymatou.iapi.couponmanage.parameter.SellerCreateBatchBean;
import com.ymatou.iapi.couponmanage.service.SellerCreateBatchCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponServiceMCallServiceV2;
import com.ymttest.database.model.couponbatch;
import com.ymttest.database.sqlwapper.couponbatchWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
/**
*获取买手有效的批次列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getValidBatchesBySeller{
	private static getValidBatchesBySellerBean getvalidbatchesbysellerBean;
	private static getValidBatchesBySellerCall getvalidbatchesbysellerCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取买手有效的批次列表");
	}

	@Before
	public void caseUp() {
		getvalidbatchesbysellerBean=new getValidBatchesBySellerBean();
		getvalidbatchesbysellerCall=new getValidBatchesBySellerCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getvalidbatchesbysellerCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_001() {
		Logger.start(true,"获取买手有效的批次列表-优惠券类型为普通-CouponType=1");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			SellerCreateBatchBean sellerCreateBatchBean2 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall2= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean2);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(1);
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			
			Logger.verifyEquals(sellerCreateBatchBean1.getSellerId(), batchVoList.get(1).getSellerId(), "验证返回sellerId1");
			Logger.verifyEquals(sellerCreateBatchBean2.getSellerId(), batchVoList.get(0).getSellerId(), "验证返回sellerId2");

			Logger.verifyEquals(createCouponCall1.getBatchCode(), batchVoList.get(1).getBatchCode(), "验证返回batchCode1");
			Logger.verifyEquals(createCouponCall2.getBatchCode(), batchVoList.get(0).getBatchCode(), "验证返回batchCode2");
			Logger.verifyEquals(2, batchVoList.size(), "验证返回batchVoList的数量");
			VerifyReturn(batchVoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_002() {
		Logger.start(true,"获取买手有效的批次列表-店铺分享券-优惠券类型为店铺分享-CouponType=2");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean1.setCouponType((byte)2);
			sellerCreateBatchBean1.setEffectiveDays(2);
			
			Date dNow = new Date(); // 当前时间
			Date dBefore = new Date();
			Date dAfter = new Date();

			Calendar calendar1 = Calendar.getInstance(); // 得到日历
			calendar1.setTime(dNow);// 把当前时间赋给日历
			calendar1.add(Calendar.DAY_OF_MONTH, -1); // 
			dBefore = calendar1.getTime(); // 得到前一天的时间

			Calendar calendar2 = Calendar.getInstance(); // 得到日历
			calendar2.setTime(dNow);// 把当前时间赋给日历
			calendar2.add(Calendar.DAY_OF_MONTH, 99999); // 
			dAfter = calendar2.getTime(); // 得到前一天的时间
			
			sellerCreateBatchBean1.setEffectiveStartDate(dBefore);
			sellerCreateBatchBean1.setEffectiveEndDate(dAfter);
			
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			SellerCreateBatchBean sellerCreateBatchBean2 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean2.setCouponType((byte)2);
			sellerCreateBatchBean2.setEffectiveDays(2);

			sellerCreateBatchBean2.setEffectiveStartDate(dBefore);
			sellerCreateBatchBean2.setEffectiveEndDate(dAfter);
			SellerCreateBatchCall createCouponCall2= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean2);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(2);
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			Logger.verifyEquals(2, batchVoList.size(), "验证返回batchVoList的数量");
			VerifyReturn(batchVoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_003() {
		Logger.start(true,"获取买手有效的批次列表-店铺分享券-优惠券类型不限-CouponType=null");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			//sellerCreateBatchBean1.setCouponType(null);
			sellerCreateBatchBean1.setEffectiveDays(2);
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			SellerCreateBatchBean sellerCreateBatchBean2 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			//sellerCreateBatchBean2.setCouponType(null);
			sellerCreateBatchBean2.setEffectiveDays(2);

			SellerCreateBatchCall createCouponCall2= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean2);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(null);
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			Logger.verifyEquals(2, batchVoList.size(), "验证返回batchVoList的数量");
			VerifyReturn(batchVoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_004() {
		Logger.start(true,"获取买手有效的批次列表-验证单条 优惠券类型为活动优惠券-CouponType=3,JIRACONN-23166");
		try {
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

//			SellerCreateBatchBean sellerCreateBatchBean2 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
//			SellerCreateBatchCall createCouponCall2= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean2);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
		//	sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(3);
			getvalidbatchesbysellerBean.setCouponTypeBizValue(sellerCreateBatchBean1.getCouponTypeBizValue());
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			
			Logger.verifyEquals(sellerCreateBatchBean1.getSellerId(), batchVoList.get(0).getSellerId(), "验证返回sellerId1");
		//	Logger.verifyEquals(sellerCreateBatchBean2.getSellerId(), batchVoList.get(0).getSellerId(), "验证返回sellerId2");

			Logger.verifyEquals(createCouponCall1.getBatchCode(), batchVoList.get(0).getBatchCode(), "验证返回batchCode1");
		//	Logger.verifyEquals(createCouponCall2.getBatchCode(), batchVoList.get(0).getBatchCode(), "验证返回batchCode2");
			Logger.verifyEquals(1, batchVoList.size(), "验证返回batchVoList的数量");
			VerifyReturn(batchVoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_004_1() {
		Logger.start(true,"获取买手有效的批次列表-验证单条 优惠券类型为活动优惠券-CouponType=3,now<acquirestarttime && now<acquireendtime,返回空,JIRACONN-23166");
		try {
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
			new couponbatchWapper().setAcquireStartTime(createCouponCall1.getBatchCode(), dBefore);
			new couponbatchWapper().setAcquireEndTime(createCouponCall1.getBatchCode(), dAfter);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(3);
			getvalidbatchesbysellerBean.setCouponTypeBizValue(sellerCreateBatchBean1.getCouponTypeBizValue());
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
		
			Logger.verifyEquals(0, batchVoList.size(), "验证返回batchVoList的数量");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_005() {
		Logger.start(true,"获取买手有效的批次列表-验证多条 优惠券类型为活动优惠券-CouponType=3,JIRACONN-23166");
		try {
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			SellerCreateBatchBean sellerCreateBatchBean2 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
			sellerCreateBatchBean2.setCouponTypeBizValue(sellerCreateBatchBean1.getCouponTypeBizValue());
			SellerCreateBatchCall createCouponCall2= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean2);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(3);
			getvalidbatchesbysellerBean.setCouponTypeBizValue(sellerCreateBatchBean1.getCouponTypeBizValue());
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();	
			Thread.sleep(5000);
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			
			Logger.verifyEquals(sellerCreateBatchBean1.getSellerId(), batchVoList.get(0).getSellerId(), "验证返回sellerId1");
			Logger.verifyEquals(sellerCreateBatchBean2.getSellerId(), batchVoList.get(1).getSellerId(), "验证返回sellerId2");

			Logger.verifyEquals(createCouponCall1.getBatchCode(), batchVoList.get(0).getBatchCode(), "验证返回batchCode1");
			Logger.verifyEquals(createCouponCall2.getBatchCode(), batchVoList.get(1).getBatchCode(), "验证返回batchCode2");
			Logger.verifyEquals(2, batchVoList.size(), "验证返回batchVoList的数量");
			VerifyReturn(batchVoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_005_1() {
		Logger.start(true,"获取买手有效的批次列表-验证多条 优惠券类型为活动优惠券-CouponType=3,多个批次的now<acquirestarttime && now<acquireendtime,JIRACONN-23166");
		try {
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			SellerCreateBatchBean sellerCreateBatchBean2 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
			sellerCreateBatchBean2.setCouponTypeBizValue(sellerCreateBatchBean1.getCouponTypeBizValue());
			SellerCreateBatchCall createCouponCall2= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean2);
			
			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
			new couponbatchWapper().setAcquireStartTime(createCouponCall1.getBatchCode(), dBefore);
			new couponbatchWapper().setAcquireEndTime(createCouponCall1.getBatchCode(), dAfter);
			new couponbatchWapper().setAcquireStartTime(createCouponCall2.getBatchCode(), dBefore);
			new couponbatchWapper().setAcquireEndTime(createCouponCall2.getBatchCode(), dAfter);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(3);
			getvalidbatchesbysellerBean.setCouponTypeBizValue(sellerCreateBatchBean1.getCouponTypeBizValue());
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();	
			Thread.sleep(5000);
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			
//			Logger.verifyEquals(sellerCreateBatchBean1.getSellerId(), batchVoList.get(0).getSellerId(), "验证返回sellerId1");
//			Logger.verifyEquals(sellerCreateBatchBean2.getSellerId(), batchVoList.get(1).getSellerId(), "验证返回sellerId2");
//
//			Logger.verifyEquals(createCouponCall1.getBatchCode(), batchVoList.get(0).getBatchCode(), "验证返回batchCode1");
//			Logger.verifyEquals(createCouponCall2.getBatchCode(), batchVoList.get(1).getBatchCode(), "验证返回batchCode2");
			Logger.verifyEquals(0, batchVoList.size(), "验证返回batchVoList的数量");
			VerifyReturn(batchVoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_005_2() {
		Logger.start(true,"获取买手有效的批次列表-验证条 优惠券类型为活动优惠券-CouponType=3,第一个批次的now<acquirestarttime && now<acquireendtime,JIRACONN-23166");
		try {
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			SellerCreateBatchBean sellerCreateBatchBean2 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
			sellerCreateBatchBean2.setCouponTypeBizValue(sellerCreateBatchBean1.getCouponTypeBizValue());
			SellerCreateBatchCall createCouponCall2= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean2);
			
			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
			new couponbatchWapper().setAcquireStartTime(createCouponCall1.getBatchCode(), dBefore);
			new couponbatchWapper().setAcquireEndTime(createCouponCall1.getBatchCode(), dAfter);
			
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			sellerIds.add(sellerCreateBatchBean2.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(3);
			getvalidbatchesbysellerBean.setCouponTypeBizValue(sellerCreateBatchBean1.getCouponTypeBizValue());
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();	
			Thread.sleep(5000);
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			
			Logger.verifyEquals(sellerCreateBatchBean2.getSellerId(), batchVoList.get(0).getSellerId(), "验证返回sellerId2");
			//Logger.verifyEquals(sellerCreateBatchBean2.getSellerId(), batchVoList.get(1).getSellerId(), "验证返回sellerId2");

			Logger.verifyEquals(createCouponCall2.getBatchCode(), batchVoList.get(0).getBatchCode(), "验证返回batchCode2");
			//Logger.verifyEquals(createCouponCall2.getBatchCode(), batchVoList.get(1).getBatchCode(), "验证返回batchCode2");
			Logger.verifyEquals(1, batchVoList.size(), "验证返回batchVoList的数量");
			VerifyReturn(batchVoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_006() {
		Logger.start(true,"获取买手有效的批次列表-验证优惠券类型为普通-CouponType=1,now<acquirestarttime && now<acquireendtime,返回为空，JIRACONN-23166");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
			new couponbatchWapper().setAcquireStartTime(createCouponCall1.getBatchCode(), dBefore);
			new couponbatchWapper().setAcquireEndTime(createCouponCall1.getBatchCode(), dAfter);
			List<Integer> sellerIds = new ArrayList<Integer>();
	
			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(1);
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			Logger.verifyEquals(0, batchVoList.size(), "验证返回batchVoList的数量");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBatchesBySeller_007() {
		Logger.start(true,"获取买手有效的批次列表-店铺分享券-优惠券类型为店铺分享-CouponType=2,now<acquirestarttime && now<acquireendtime,返回为空，JIRACONN-23166");
		try {
			
			int userId = TestDataManager.getRandomIntNum(8);
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean1 = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean1.setCouponType((byte)2);
			sellerCreateBatchBean1.setEffectiveDays(2);
			SellerCreateBatchCall createCouponCall1= CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean1);		

			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
			new couponbatchWapper().setAcquireStartTime(createCouponCall1.getBatchCode(), dBefore);
			new couponbatchWapper().setAcquireEndTime(createCouponCall1.getBatchCode(), dAfter);

			List<Integer> sellerIds = new ArrayList<Integer>();

			sellerIds.add(sellerCreateBatchBean1.getSellerId());
			
			getvalidbatchesbysellerBean.setSellerIds(sellerIds);
			getvalidbatchesbysellerBean.setCouponType(2);
			
			getvalidbatchesbysellerCall.setData(getvalidbatchesbysellerBean);
			getvalidbatchesbysellerCall.callService();		
			
			Logger.verifyEquals("0", getvalidbatchesbysellerCall.getStatusCode1(), "验证返回statusCode");
			
			GetValidBatchesBySellerResp getValidBatchesBySellerResp = getvalidbatchesbysellerCall.GetValidBatchesBySellerResp();
			
			List<BatchVo> batchVoList = getValidBatchesBySellerResp.getBatchVoList();
			Logger.verifyEquals(0, batchVoList.size(), "验证返回batchVoList的数量");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	private void VerifyReturn(List<BatchVo> batchVoList) throws ParseException
	{
		for(BatchVo vo:batchVoList)
		{
			Map couponbatch=new couponbatchWapper().getCouponBatchByOperatorId(vo.getSellerId()).get(0);
			Logger.verifyEquals(vo.getSellerId(), Integer.parseInt(couponbatch.get("OperatorId").toString()), "验证返回sellerId");
			Logger.verifyEquals(vo.getBatchId(), Integer.parseInt(couponbatch.get("BatchId").toString()), "验证返回batchId");
			Logger.verifyEquals(vo.getBatchCode(), couponbatch.get("BatchCode").toString(), "验证返回batchCode");
			Logger.verifyEquals(vo.getCouponCount(), Integer.parseInt(couponbatch.get("TotalNum").toString()), "验证返回CouponCount");
			Logger.verifyEquals(vo.getReceivedCount(), Integer.parseInt(couponbatch.get("ReceivedCount").toString()), "验证返回ReceivedCount");
			Logger.verifyEquals(vo.getMinOrderValue(),new BigDecimal(couponbatch.get("MinOrderValue").toString()).stripTrailingZeros(), "验证返回MinOrderValue");
			if(Integer.parseInt((couponbatch.get("AcquireMethod").toString()))!=3){
			  Logger.verifyEquals(1, couponbatch.get("AcquireMethod"), "验证返回AcquireMethod");
			}
			else
			{
				Logger.verifyEquals(3, Integer.parseInt((couponbatch.get("AcquireMethod").toString())), "验证返回AcquireMethod");
			}
			 
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Logger.verifyEquals(formatter.format(vo.getValidStart()), couponbatch.get("ValidStart").toString().substring(0, 19), "验证返回validStart");
			Logger.verifyEquals(formatter.format(vo.getValidEnd()), couponbatch.get("ValidEnd").toString().substring(0, 19), "验证返回ValidEnd");
			
			Logger.verifyEquals(formatter.format(vo.getAcquireStartTime()), couponbatch.get("AcquireStartTime").toString().substring(0, 19), "验证返回acquireStartTime");
			Logger.verifyEquals(formatter.format(vo.getAcquireEndTime()), couponbatch.get("AcquireEndTime").toString().substring(0, 19), "验证返回acquireEndTime");
		}
	}
}